<div class="chapter-navi visible-xs" class="row">
    <span class="menu-button" id="tblcontents"><i class="fa fa-bars"></i></span>
</div>

<div class="col-md-12 col-sm-12 col-lg-10 ctnWpr">
    <h2 class="text-primary">Danh sách truyện</h2><br><br>
    <table class="table table-hover"> 
        <thead>
            <tr>
                <th>Tên truyện</th>
                <th class="text-center">Mới nhất</th>
                <th>Tác giả</th>
                <th>Thể loại</th>
                <th class="text-right">Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($allNovel as $m): ?>
            <?php $lastChapter = $m->chapter[0]['chapter']; ?>
                <tr>
                    <td>
                        <a href="<?= base_url() ?>truyen/<?= $m->slug ?>" alt="<?= $m->name ?>" title="<?= $m->name ?>">
                            <?= $m->name ?>
                        </a>
                    </td>
                    <td class="text-center">
                        <?php $lastChapter = $m->chapter[0]['chapter']; ?>
                        <a href="<?= base_url() ?>/truyen/<?= $m->slug ?>/chuong/<?=$lastChapter?>">
                            <span class="badge"><?=$lastChapter?></span>
                        </a>
                    </td>
                    <td>
                        <?=$m->author ?>
                    </td>
                    <td>
                        <?php $i = 0;
                            foreach($m->cats as $c) {
                                echo '<a href="/the-loai/' . $c->slug . '">' . $c->name . '</a>';
                                if(++$i != count($m->cats))
                                    echo ', ';
                            }
                        ?>
                    </td>
                    <td class="text-right">
                        <?php 
                            $text = $m->status == 1 ? 'Đang cập nhật' : ($m->status == 2 ? 'Hoàn thành' : 'tạm dừng');
                            $color = $m->status == 1 ? 'success' : ($m->status == 2 ? 'primary' : 'danger');
                        ?>
                        <span class="label label-<?=$color?>"><?=$text?></span>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>